<?php
/**
 * 短息发送模块
 * @author jroam
 *
 */
class smsAction extends Action{
	
	/**
	 * 发送单条短息
	 * @param $data $data["phoneno"]手机号  $data["content"]发送内容
	 * @return 成功返回 true 失败返回false
	 */
	function sendsms($data){
		
		//验证数据
		/**
		if(!$data) return false;
		if(!preg_match("/^1[\d]{10}$/", $data["phoneno"])) return false;
		if($data["content"]=="" or !$data["content"]) return false;
		*/
		//短信接口用户名 $uid
		global $SYS_config;
		$uid = $SYS_config["smsuser"];
		//短信接口密码 $passwd
		$passwd =  $SYS_config["smspass"];;
		//发送到的目标手机号码 $telphone
		$telphone = $data["phoneno"];
		//短信内容 $message
		$message = mb_convert_encoding($data["content"], "GB2312", "utf-8");
		//iconv("UTF-8","GB2312//TRANSLIT",$message);
		
		//$message=urlencode($message);
		$url="CorpID={$uid}&Pwd={$passwd}&Mobile={$telphone}&Content={$message}&Cell=&SendTime=";
		$gateway = "http://mb345.com:999/ws/batchSend.aspx?".$url;
		
		$result = file_get_contents($gateway);
		return ($result>=0)?true:false;
		
	}
	
	/**
	 * 
	 * @param $data $data["phoneno"]手机号  $data["content"]内容
	 * 
	 */
	function senddx($data){
		
		if(!preg_match("/^1[\d]{10}$/", $data["phoneno"])) return("手机号格式不对");
		if($data["content"]=="") return("内容不能不空");
		$data["content"]=$data["content"];
		
		return $this->sendsms($data)?"suss":"pass";
	}
	
	
}

?>